﻿@{
    var path = ViewData["path"] as string;

    <p class="breadcrumbs">
        <em>@Html.ActionLink(Resources.Repository_AddressBar_Root, "Tree", new { id = ViewBag.ID, encodedPath = "" })</em>
        @if (path != null)
        {
            <text>/</text>
            var dirs = path.Split('/');
            for (int i = 0; i < dirs.Length; i++)
            {
                string currentPath = string.Empty;
                for (int j = 0; j < i; j++)
                {
                    currentPath += dirs[j] + "/";
                }
                currentPath += dirs[i];

                if (new string[] { "Blame", "Blob" }.Contains((string)ViewContext.RouteData.Values["Action"]) && i + 1 == dirs.Length)
                {
                    <em>@dirs[i]</em>
                }
                else
                {
                    @Html.ActionLink(dirs[i], "Tree", new { encodedPath = PathEncoder.Encode(currentPath, allowSlash: true), id = ViewBag.ID })
                }

                if (i + 1 != dirs.Length)
                {
                    <text>/</text>
                }
            }
        }
    </p>
}